<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <!--<meta name="viewport" content="width=device-width, initial-scale=1"/>-->
    <link rel="stylesheet" href="../../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}"/>
    <link rel="stylesheet" href="../../static/css/bootstrap-theme.min.css" th:href="@{/css/bootstrap-theme.min.css}"/>
    <link rel="stylesheet" href="../../static/css/show.css" th:href="@{/css/hotel.css}"/>
    <title>Tickets经理</title>
</head>
<body>

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.html" th:href="@{index}">寻票</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a class="" href="index.html" th:href="@{index}">消息<span
                        class="badge">4</span><span
                        class="sr-only">(current)</span></a></li>
                <li class="active"><a href="settle-account.html" th:href="@{settlements}">演出结算</a></li>
                <li><a href="statistics.html" th:href="@{statistics}">网站统计</a></li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>


<div class="mainpage">

    <div class="panel panel-info" id="settlementsTable">
        <!-- Default panel contents -->
        <div class="panel-heading">演出结算</div>
        <div class="table-responsive ">
            <table class="table table-hover" id="openTable">
                <tr>
                    <th>场馆名称</th>
                    <th>演出名称</th>
                    <th>演出时间</th>
                    <th>总收入</th>
                    <th>结算比率</th>
                    <th>结算金额</th>
                    <th>结算状态</th>
                </tr>
                <tr th:each="settle : ${settlements}"
                    th:class="info">
                    <td th:text="${settle.venueName}"></td>
                    <td id="showName" th:text="${settle.showName}"></td>
                    <td th:text="${settle.performanceTime}"></td>
                    <td th:text="${settle.totalBenefit}"></td>
                    <td th:text="${settle.ratio}"></td>
                    <td th:text="${settle.settlementAmount}"></td>
                    <td th:text="(${settle.status == 0}) ? '已结算' : '未结算'"></td>
                    <td>
                        <a class="btn-primary operation" name="singleApprove"><span
                                class="glyphicon glyphicon-ok"
                                aria-hidden="true"></span></a>
                        <a class="btn-danger operation" name="singleDeny"><span
                                class="glyphicon glyphicon-remove"
                                aria-hidden="true"></span></a>
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <div class="alert alert-danger invisible" role="alert"></div>
</div>

<!--Scripts-->
<script src="../../static/js/jquery-3.1.1.min.js" th:src="@{/js/jquery-3.1.1.min.js}"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<script src="../../static/js/npm.js" th:src="@{/js/npm.js}"></script>
<script src="../../static/js/promptForm.js" th:src="@{/js/promptForm.js}"></script>
<script th:inline="javascript">
    $('.operation').on('click', function (e) {
        e.preventDefault();
        var source = $(this).attr('name');
        var isSingle = true;
        var isApprove = true;
        switch (source) {
            case 'singleApprove':
                isSingle = true;
                isApprove = true;
                break;
            case 'singleDeny' :
                isSingle = true;
                isApprove = false;
                break;
            default:
                break;
        }

        var operationArray = [];
        if (isSingle) {
            operationArray.push($(this).parent().parent().find('input[type="checkbox"]').attr('name'));
        }

        var showName = $("#showName").text();
        console.log(showName);

        var inputs = {isApprove: isApprove, showName: showName};
        console.log(inputs);
        $.ajax({
            type: "POST",
            url: '/admin/settlements',
            data: inputs,
            dataType: 'json',
            success: function (data) {
                if (data.code == 200) {
                    location.reload();
                } else {
                    var error_msg = '<p class="errtip">	<strong>Error</strong>：' + data.reason + '</p>'
                    $(".alert-danger").html(error_msg).removeClass("invisible");
                }

            }
        });
    });
</script>
</body>
</html>